<?php
/**
 * 录音页详情
 */
//require_once dirname(__DIR__)."/common.php";
require_once "login_filter.php";
use app\cls\tom\Response;
use app\cls\tom\SysResource;
use app\model\Topic;


$id=$_REQUEST['id'];
if(empty($id)){
    Response::output(-1,"参数错误");
}
$type=substr($id,0,5);
if(!in_array($type,["luyin","sucai"])){
    Response::output(-1,"不支持的类型");
}
$id_len=strlen($id);
$ids=substr($id,6,$id_len);

//实例化数据库
$db = SysResource::getDB(false);
$Topic = new Topic($db);
if($type=="sucai"){
    $video_detail=$Topic->erweima_user_material_detail($ids);

    //再去根据用户自己的ID去查询用户点赞和关注了哪些视频
    $uuid=$Auth['uuid'];
//$uuid=2;
//查询已点赞视频
    $zan=$Topic->zan($uuid);
//查询已关注视频
    $guanzu=$Topic->guanzu($uuid);
    $zans=[];
    $zan_id=[];
    $guanzus=[];

    if(!empty($video_detail)){
        foreach($zan as $k=>$v){
            $zans[]=$v['video_uuid'];
            $zan_id[]=$v['other_id'];
        }
        foreach($guanzu as $kk=>$vv){
            $guanzus[]=$vv['other_uuid'];
        }

        if(in_array($video_detail['video_uuid'],$zans) && in_array($video_detail['id'],$zan_id)){
            $video_detail['is_zan']=2;
        }else{
            $video_detail['is_zan']=1;
        }
        if(in_array($video_detail['uuid'],$guanzus)){
            $video_detail['is_follow']=2;
        }else{
            $video_detail['is_follow']=1;
        }
        if($video_detail['uuid']==$uuid){
            $video_detail['is_dub']=3;
        }
        if($video_detail['uuid']==$uuid){
            $video_detail['is_user']=1;
        }else{
            $video_detail['is_user']=0;
        }
        if(empty($video_detail['share_pic'])){
            $video_detail['share_pic']="";
        }
        if(empty($video_detail['video_desc'])){
            $video_detail['video_desc']="";
        }
        $video_detail['count_material_love_10']=round($video_detail['count_material_love']*1.7);
        $video_detail['count_material_share_10']=round($video_detail['count_material_share']*1.7);

        Response::output(0,"查询成功",$video_detail);
    }else{
        Response::output(0,"查询成功",[]);
    }
}